package com.qiyadeng.thread;

public class ThreadExample {

	public static void main(String[] args) {
		
		//death lock
		TreeNode parentNode = new TreeNode();
		TreeNode childNode = new TreeNode();
		Thread childThread = new Thread(new ChildTreeNode(parentNode,childNode));
		Thread parentThread = new Thread(new ParentTreeeNode(childNode,parentNode));
		
		childThread.start();
		parentThread.start();
		
		
		
		
		
		
		/*
		//Thread wait and notify;
		MyWaitNotify myWaitNotify = new MyWaitNotify();
		WaitThread waitThread = new WaitThread(myWaitNotify);
		WaitThread waitThread2 = new WaitThread(myWaitNotify);
		NotfiyThread notfiyThread = new NotfiyThread(myWaitNotify);
		
		notfiyThread.start();
		new Thread(waitThread).start();
		//waitThread2.start();
		*/
		
		/*//1.thread name
		System.out.println("main thread name=" + Thread.currentThread().getName());
		
		for (int i = 0; i < 10; i++) {
			new Thread("helloworld" + i){
					public void run() {
						System.out.println("thread = "+getName());
					}
			}.start();
		
		}*/
		
		/*//not safe thread demo
		NotThreadSafe instance = new NotThreadSafe();
		new Thread(new MyRunnable(instance)).start();
		new Thread(new MyRunnable(instance)).start();
		*/
		
		/*
		Counter counter1 = new Counter();
		Counter counter2 = new Counter();
		CounterThread ct1 = new CounterThread(counter1);
		CopyOfCounterThread ct2 = new CopyOfCounterThread(counter1);
		ct1.start();
		ct2.start();
		*/
		
	}
}
